package com.jlboot.core.util;


/**
 * Created by 51594 on 2022/7/28.
 */
public class FileUtil {


    /**
     * @param oldName
     * @return
     */
    public static String getFileRename(String oldName) {
        int index = oldName.lastIndexOf(".");
        String ext = oldName.substring(index, oldName.length());
        if (ext != null) ext = ext.toLowerCase();
        //TODO 文件名可能重复
        long filename = DateUtil.getDate().getTime();
        return filename + ext;
    }

    /**
     * @param oldName
     * @return
     */
    //TODO 文件名可能重复
    public static String getFileRename(String oldName, long newlongs) {
        int index = oldName.lastIndexOf(".");
        String ext = oldName.substring(index, oldName.length());
        if (ext.indexOf(".png") > -1) ext = ".png";
        if (ext.indexOf(".jpg") > -1) ext = ".jpg";
        if (ext.indexOf(".gif") > -1) ext = ".gif";
        if (ext != null) ext = ext.toLowerCase();
        return newlongs + ext;
    }


}
